<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // all方法 等待多有的promise对象返回结果，一块输出

        //请求1
        let p1 = new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log(1111)
                resolve(1)
            }, 4000)
        })
        //请求2
        let p2 = new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log(222)
                resolve(2)
            }, 6000)
        })
        //请求3
        let p3 = new Promise((resolve, reject) => {
            setTimeout(() => {
                console.log(333)
                resolve(3)
            }, 3000)
        })

        // Promise.all([p1,p2,p3]).then((res)=>{
        //     console.log(res)
        // })

        Promise.race([p1, p2, p3]).then((res) => {
            console.log(res);
        })
        //Promise.race传入的promise 对象那个结果获取最快旧输出那个结果
    </script>
</body>

</html>